import os

if __name__ == '__main__':
    # 加载django项目的配置信息
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blogproject.settings")
    # 导入django,并启动django项目
    import django
    from blogproject import settings
    from django.core.mail import send_mail

    django.setup()

    msg_from = settings.EMAIL_HOST_USER  # 发送人地址
    pwd = 'eyumzblhadbmdgcf'  # smtp授权码
    to = settings.EMAIL_HOST_USER  # 发送人地址
    subject = '这是python发送的'  # 电子邮件主题
    content = 'hello world'  # 发送内容

    send_mail(
        subject=subject,
        message=content,
        from_email=to,
        recipient_list=[to],

    )
